function debug.printTable(table, maxDepth, currentDepth)

	if not maxDepth then maxDepth = 0 end
	if not currentDepth then currentDepth = 1 end

	for k, v in pairs(table) do
	
		local compensationTab = ""
		for i = 0, 20 - string.len(tostring(k)) do compensationTab = compensationTab .. " " end
	
		local hierarchyTab = ""
		for i = 0, currentDepth do hierarchyTab = hierarchyTab .. "\t" end
		
		if (type(v) ~= "table") then
			print(hierarchyTab .. tostring(k) .. compensationTab .. tostring(v))
		else
			print(hierarchyTab .. tostring(k) .. " :")
		end
		
		if 
			(type(v) == "table") and
			(maxDepth > 0)
		then
			debug.printTable(v, maxDepth - 1, currentDepth + 1)
		end
	end
end

---

function debug.tableToString(table)

	local keyString = ""
	local valueString = ""
	
	for key, value in pairs(table) do
	
		keyString = keyString .. key .. "\n"
		valueString = valueString .. value .. "\n"			
	
	end
	
	return keyString, valueString
end

---

function debug.printParents(table)

	if type(getmetatable(table)["__index"]) == "table" then
	
		print ("Parent:")
		debug.printTable(getmetatable(table)["__index"])
		
		if getmetatable(table)["__index"] then
			debug.printParents(getmetatable(table)["__index"])
		end
	end
end
